﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace WCSY.BLL
{
    public class wcsy_costsOrderMstManager
    {
        private readonly WCSY.DAL.wcsy_costsOrderMstService dal=new WCSY.DAL.wcsy_costsOrderMstService();
        public wcsy_costsOrderMstManager()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string sysno)
		{
			return dal.Exists(sysno);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public string Add(WCSY.MODEL.wcsy_costsOrderMst MODEL)
		{
			return dal.Add(MODEL);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public string Update(WCSY.MODEL.wcsy_costsOrderMst MODEL)
		{
			return dal.Update(MODEL);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public string Delete(string sysno)
		{
			
			return dal.Delete(sysno);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string sysnolist )
		{
			return dal.DeleteList(sysnolist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public WCSY.MODEL.wcsy_costsOrderMst GetMODEL(string sysno)
		{
			
			return dal.GetMODEL(sysno);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
        /// <summary>
        /// 根据参数查询数据列表
        /// </summary>
        /// <param name="sysno"></param>
        /// <param name="dept"></param>
        /// <param name="applypsn"></param>
        /// <param name="fillpsn"></param>
        /// <param name="filldateB"></param>
        /// <param name="filldateE"></param>
        /// <returns></returns>
        public DataSet GetAllListByPara(string sysno, string dept, string applypsn, string fillpsn, string filldateB, string filldateE)
        {
            return dal.GetAllListByPara(sysno,dept,applypsn,fillpsn,filldateB,filldateE);
        }
         /// <summary>
        /// 双击费用执行汇总查询费用明细表
        /// </summary>
        /// <param name="busysno"></param>
        /// <param name="deptno"></param>
        /// <param name="costsno"></param>
        /// <returns></returns>
        public DataTable GetOrderListByPara(string busysno, string deptno, string costsno)
        {
            return dal.GetOrderListByPara(busysno, deptno, costsno);
        }
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<WCSY.MODEL.wcsy_costsOrderMst> GetMODELList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<WCSY.MODEL.wcsy_costsOrderMst> DataTableToList(DataTable dt)
		{
			List<WCSY.MODEL.wcsy_costsOrderMst> MODELList = new List<WCSY.MODEL.wcsy_costsOrderMst>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				WCSY.MODEL.wcsy_costsOrderMst MODEL;
				for (int n = 0; n < rowsCount; n++)
				{
					MODEL = new WCSY.MODEL.wcsy_costsOrderMst();
					if(dt.Rows[n]["sysno"]!=null && dt.Rows[n]["sysno"].ToString()!="")
					{
					MODEL.sysno=dt.Rows[n]["sysno"].ToString();
					}
					if(dt.Rows[n]["applyPsn"]!=null && dt.Rows[n]["applyPsn"].ToString()!="")
					{
					MODEL.applyPsn=dt.Rows[n]["applyPsn"].ToString();
					}
					if(dt.Rows[n]["applyDept"]!=null && dt.Rows[n]["applyDept"].ToString()!="")
					{
					MODEL.applyDept=dt.Rows[n]["applyDept"].ToString();
					}
					if(dt.Rows[n]["costOfDateB"]!=null && dt.Rows[n]["costOfDateB"].ToString()!="")
					{
						MODEL.costOfDateB=DateTime.Parse(dt.Rows[n]["costOfDateB"].ToString());
					}
					if(dt.Rows[n]["costOfDateE"]!=null && dt.Rows[n]["costOfDateE"].ToString()!="")
					{
						MODEL.costOfDateE=DateTime.Parse(dt.Rows[n]["costOfDateE"].ToString());
					}
					if(dt.Rows[n]["costUse"]!=null && dt.Rows[n]["costUse"].ToString()!="")
					{
					MODEL.costUse=dt.Rows[n]["costUse"].ToString();
					}
					if(dt.Rows[n]["remarks"]!=null && dt.Rows[n]["remarks"].ToString()!="")
					{
					MODEL.remarks=dt.Rows[n]["remarks"].ToString();
					}
					if(dt.Rows[n]["fillpsn"]!=null && dt.Rows[n]["fillpsn"].ToString()!="")
					{
					MODEL.fillpsn=dt.Rows[n]["fillpsn"].ToString();
					}
					if(dt.Rows[n]["filldate"]!=null && dt.Rows[n]["filldate"].ToString()!="")
					{
						MODEL.filldate=DateTime.Parse(dt.Rows[n]["filldate"].ToString());
					}
					if(dt.Rows[n]["authorPsn"]!=null && dt.Rows[n]["authorPsn"].ToString()!="")
					{
					MODEL.authorPsn=dt.Rows[n]["authorPsn"].ToString();
					}
					if(dt.Rows[n]["authorDate"]!=null && dt.Rows[n]["authorDate"].ToString()!="")
					{
						MODEL.authorDate=DateTime.Parse(dt.Rows[n]["authorDate"].ToString());
					}
					MODELList.Add(MODEL);
				}
			}
			return MODELList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}
        /// <summary>
        /// 获取部门费用执行汇总表
        /// </summary>
        /// <param name="deptno"></param>
        /// <param name="costsno"></param>
        /// <param name="uyear"></param>
        /// <param name="period"></param>
        /// <returns></returns>
        public DataTable getBuActioveSumReport(string deptno, string costsno, string uyear, string period)
        {
            return dal.getBuActioveSumReport( deptno,  costsno,  uyear,  period);
        }

         /// <summary>
        /// 查询费用明细表
        /// </summary>
        /// <param name="busysno"></param>
        /// <param name="deptno"></param>
        /// <param name="costsno"></param>
        /// <returns></returns>
        public DataTable GetActiovOrderListByPara(string deptno, string costsno, string uyear, string period)
        {
            return dal.GetActiovOrderListByPara( deptno,  costsno,  uyear,  period);
        }
		#endregion  Method
    }
}
